import {ICountAction} from "../actions/count";

export interface ICountState {
  readonly count: number;
}

const initialState: ICountState = {
  count: 0
}

const count =  (state: ICountState = initialState, action: ICountAction): ICountState => {
  switch (action.type) {
    case "ADD_COUNT":
      return {count: state.count + action.payload}
    case "SET_COUNT":
      return {...state, count: action.payload}
    default:
      return state
  }
}

export default count
